package com.ml.mall.api.payment;

import com.ml.mall.annotation.LogMethodInvokeInformation;
import com.ml.mall.bean.base.ApiRestResult;
import com.ml.mall.bean.req.payment.PaymentRecordQueryAllDto;
import com.ml.mall.consts.PermissionConst;
import com.ml.mall.entity.payinfo.SysPaymentRecord;
import com.ml.mall.enums.CommonEnum;
import com.ml.mall.exception.BizException;
import com.ml.mall.service.payinfo.SysPaymentRecordService;
import io.swagger.annotations.Api;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * @description 【order】 支付记录接口
 * @author yx
 * @date 2021/10/12
 * @version 1.0
*/
@Api(tags = "【order】支付记录接口")
@RestController
@RequestMapping("/payment_record")
public class SysPaymentRecordController {
    @Autowired
    private SysPaymentRecordService sysPaymentRecordService;

    @PostMapping("/query_all")
    @LogMethodInvokeInformation("查询支付记录")
//    @RequiresPermissions(PermissionConst.PAYMENT_RECORD_QUERY_ALL)
    public ApiRestResult paymentRecordQueryAll(@RequestBody @Valid PaymentRecordQueryAllDto dto){
        List<SysPaymentRecord> result = sysPaymentRecordService.queryAll(dto);
        if(null == result){
            throw new BizException(CommonEnum.SELECT_ERROR);
        }
        return ApiRestResult.ok(result);
    }
}
